package com.framework.repository;

import com.framework.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.UUID;

/**
 * @Description: UserRole表实体
 * @Author: JamesYao
 * @DateTime: 2024/2/19 17:06
 */
public interface UserRoleRepository extends JpaRepository<UserRole, UUID> {
    void deleteAllByUserId(UUID userId);
    @Modifying
    @Query("UPDATE UserRole u SET u.roleId = ?1 WHERE u.userId = ?2")
    void updateRoleByUserId(UUID roleId, UUID userId);
}
